<?php
namespace app\qrcode\controller;
use think\Controller;
use Endroid\QrCode\QrCode;
use Endroid\QrCode\Response\QrCodeResponse;
header("Access-Control-Allow-Origin:*");
header("Access-Control-Allow-Methods:GET,POST");
header("Access-Control-Allow-Headers:x-requested-with,content-type");
class Index  extends Controller
{
    public function index()
    {
        $input = input();
        if(!$input['text']) {
            return false;
        }
        $text = $input['text'];
        $text = str_replace('%26','&',$text);
        $qrCode = new QrCode($text);
        header('Content-Type: '.$qrCode->getContentType());
        $response = new QrCodeResponse($qrCode);
        return $response->send();
    }
}
